import 'package:flutter/material.dart';

class timeline extends StatelessWidget {
  final Color? bgColor;
  final bool? isLast;
  final String? title;
  final String? subtitle;
  final String? content;

  const timeline(
      {super.key,
      this.bgColor,
      this.isLast,
      this.title,
      this.subtitle,
      this.content});

  @override
  Widget build(BuildContext context) {
    //创建一个时间线控件
    return IntrinsicHeight(
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Column(
            children: [
              Container(
                width: 24,
                height: 24,
                decoration: BoxDecoration(
                  shape: BoxShape.circle,
                  color: bgColor,
                ),
              ),
              isLast!
                  ? const SizedBox.shrink()
                  : Expanded(
                      child: Padding(
                        padding: const EdgeInsets.only(top: 8, bottom: 8),
                        child: Container(
                          width: 2,
                          color: bgColor,
                        ),
                      ),
                    ),
            ],
          ),
          const SizedBox(
            width: 16,
          ),
          Expanded(
              child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                title ?? "",
                style: const TextStyle(fontSize: 20),
              ),
              Text(subtitle ?? "",
                  style: const TextStyle(fontSize: 16, color: Colors.grey)),
              const SizedBox(
                height: 5.0,
              ),
              ConstrainedBox(
                constraints: const BoxConstraints(minHeight: 60),
                child: Container(
                  width: double.infinity,
                  margin: const EdgeInsets.only(bottom: 8.0, right: 8.0),
                  decoration: BoxDecoration(
                    color: Colors.orange.withOpacity(0.1),
                    borderRadius: BorderRadius.circular(5),
                  ),
                  child: Text(content ?? ""),
                ),
              ),
            ],
          ))
        ],
      ),
    );
  }
}
